Clear[n,fs];
f[x_]:=Piecewise[{{-1,-Pi<x<0},{1,0<x<Pi}}];fourierseries=RecurrenceTable[{fs[n]==2 Re[FourierCoefficient[f[x],x,n]]Cos[n x] -2 Im[FourierCoefficient[f[x],x,n]] Sin[n x]+fs[n-1], fs[0]==FourierCoefficient[f[x],x,0]},fs,{n,0,30}];ListAnimate[Table[Plot[{f[x],fourierseries[[n]]},{x,-Pi,Pi},PlotRange->{{-Pi-0.1,Pi+0.1},{-1.75,1.75}}],{n,0,30}]]

Clear[n,fs];
f[x_]:=Abs[x];
g[x_]:=Piecewise[{{Abs[x+2Pi],-2Pi<x<-Pi},{Abs[x],-Pi<x<Pi},{Abs[x-2Pi],Pi<x<2Pi}}];fourierseries=+RecurrenceTable[{fs[n]==2 Re[FourierCoefficient[f[x],x,n]]Cos[n x] -2 Im[FourierCoefficient[f[x],x,n]] Sin[n x]+fs[n-1], fs[0]==FourierCoefficient[f[x],x,0]},fs,{n,0,30}];ListAnimate[Table[Plot[{g[x],fourierseries[[n]]},{x,-2Pi-1,2Pi+1},PlotRange->{{-2Pi-0.1,2Pi+0.1},{-0.1,Pi+1}}],{n,0,10}]]